<template>
  <div class="getFavList">
    <div class="getFavList-header">
      <van-nav-bar
        class="getFavList-bar"
        title="收藏列表"
        left-arrow
        fixed
        @click-left="$router.back()"
      />
    </div>
    <div class="getFavList-text" v-for="i in article" :key="i._id" >
  
          <p>{{ i.title }}</p>
          <img v-for="img in i.imageSrc" :src="img" alt="" :key="img._id" />
          <p>
            用户：{{ i.author }} 评论：{{ i.comment }} 时间：{{
              i.time | formatDate
            }}
          </p>
           
        </div>
  </div>
  
</template>

<script>
import {getFavList} from '@/api/api';
import {Toast} from 'vant';
export default {
  data(){
    return {
      uid:'',
      skip:0,
      limit:10,
      article:[]

    }
  },
  filters: {
    formatDate(value) {
      // 时间戳转换日期格式方法
      if (value == null) {
        return "";
      } else {
        let date = new Date(value);
        let y = date.getFullYear(); // 年
        let MM = date.getMonth() + 1; // 月
        MM = MM < 10 ? "0" + MM : MM;
        let d = date.getDate(); // 日
        d = d < 10 ? "0" + d : d;
        let h = date.getHours(); // 时
        h = h < 10 ? "0" + h : h;
        let m = date.getMinutes(); // 分
        m = m < 10 ? "0" + m : m;
        let s = date.getSeconds(); // 秒
        s = s < 10 ? "0" + s : s;
        return y + "-" + MM + "-" + d + " " + h + ":" + m + ":" + s;
        return y + "-" + MM + "-" + d;
      }
    },
  },
  mounted(){
    this.uid = localStorage.getItem("uid");
    this.collectList();
  },
  methods:{
    //获取收藏列表
      collectList(){
      let {uid,skip,limit} = this
      getFavList(
        {user_id:uid,skip,limit}
      ).then((res)=>{
        console.log(res);
        this.article=res.data.data
      })
    }
  },
}


</script>

<style>
.getFavList {
  overflow-y: auto;
  padding-bottom: 150px;
}
.getFavList-bar {
  background: #07c060;
}

.getFavList-nav {
  width: 100%;
  /* position: relative; */
}
.getFavList-text {
  margin-top: 70px;
  width: 100%;
}
.getFavList-text img {
  max-width: 100%;
}
.getFavList-text p {
  text-align: center;
  overflow: hidden;
}

.van-nav-bar__title {
  color: white;
}
</style>